'use strict';
/**
 * @author  majintao
 * @version  [1.0.0, 2017/10/16]
 * @see MonitorRecordService.js
 * @since  1.0.0
 */
(function ($, app) {
    /**
     * 消息中心模态框-控制器
     */
    app.controller('InfoDetailCtrl', ['$scope', '$state','$uibModalInstance','param','InfocenterService',function ($scope, $state, $uibModalInstance,param,InfocenterService) {
    	var vm = $scope.vm = this;
    	
    	vm.info = param;
    	
    	//将消息设为已读
    	//如果该消息已读，则不处理
    	if(!param.status){
    		InfocenterService.setRead(param.infoId).then(function(data){
    		});
    	}
    	//去页面查看
    	vm.gotoView = function(){
    		$uibModalInstance.close();
    		//三方协同跳转页面需带参数，特殊处理
    		var searchCode = param.infoType.searchCode
    		if(searchCode.indexOf("3|") != 0 && searchCode.indexOf("7|") != 0){
    			$state.go(param.turnTo);
    		}else if(searchCode.indexOf("7|") == 0){
    			$state.go(param.turnTo,{userId:param.loginUser.id});
    		}
    		else{
    			var action = "";
    			switch(searchCode){
    			case "3|1":
    			case "3|2":
    				action = "accept";break;
    			case "3|3":
    			case "3|4":
    				action = "report";break;
    			}
    			$state.go(param.turnTo,{action:action});
    		}
    		
    	}
        //关闭模态框
        vm.close = function(){
        	$uibModalInstance.close();
        };
    }]);

    
})(jQuery, app);
